<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>AddElement</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">AddElement()</font></b></p>
<p><b>语法</b></p><blockquote>

Result = <font color="#006666"><b>AddElement</b></font>(List())</blockquote>

<b>概要</b><br><blockquote>



Adds a new empty element after the current element or as the first item in the 
list if there are no elements in it. This new element becomes the current 
element of the list. 

 

</blockquote><p><b>参数</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>List()</i></td>
<td width="90%"> 
 
The name of your list variable, created with the <a href="../reference/newlist.html">NewList</a> function. 
You must include the brackets after the list name. 

 

</td></tr>
</table>
</blockquote><p><b>返回值</b></p><blockquote>



Returns non-zero if the new element was created and zero otherwise. The value returned is 
a <a href="../reference/memory.html">pointer</a> to the new element data. 

 

</blockquote><p><b>示例</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <font color="#006666">; The simplest way to use AddElement</font>
  <b><font color="#006666">NewList</font></b> <font color="#006666">simple</font>.w()
<font color="#006666">  AddElement</font>(<font color="#006666">simple</font>())    <font color="#006666">; Creates the first new element in the list</font>
<font color="#006666">  simple</font>() = 23

<font color="#006666">  AddElement</font>(<font color="#006666">simple</font>())    <font color="#006666">; Current position is the first element, so we add one to the second position</font>
<font color="#006666">  simple</font>() = 45


  <font color="#006666">; This shows how to use the return-value of AddElement</font>
  <b><font color="#006666">NewList</font></b> <font color="#006666">advanced</font>.l()
  <b><font color="#006666">If</font></b> <font color="#006666">AddElement</font>(<font color="#006666">advanced</font>()) &lt;&gt; 0
<font color="#006666">    advanced</font>() = 12345
  <b><font color="#006666">Else</font></b>
<font color="#006666">    MessageRequester</font>("Error!", "Unable to allocate memory for new element", <font color="#924B72">#PB_MessageRequester_OK</font>)
  <b><font color="#006666">EndIf</font></b>


  <font color="#006666">; A small structure to demonstrate the use of the pointer to the new element</font>
  <b><font color="#006666">Structure</font></b> Programmer
    Name.s
    Strength.b
  <b><font color="#006666">EndStructure</font></b>

  <b><font color="#006666">NewList</font></b> <font color="#006666">Programmers</font>.Programmer()  <font color="#006666">; The list for storing the elements</font>

  *Element.Programmer =<font color="#006666"> AddElement</font>(<font color="#006666">Programmers</font>())
  <b><font color="#006666">If</font></b> *Element&lt;&gt;0
    *Element\Name = "Dave"
    *Element\Strength = 3   <font color="#006666">; Wow, super-strong geek! ;)</font>
  <b><font color="#006666">Else</font></b>
<font color="#006666">    MessageRequester</font>("Error!", "Unable to allocate memory for new element", <font color="#924B72">#PB_MessageRequester_OK</font>)
  <b><font color="#006666">EndIf</font></b>
</font></pre>

</blockquote><p><b>参阅</b></p><blockquote>

<a href="insertelement.html">InsertElement()</a>, <a href="deleteelement.html">DeleteElement()</a>, <a href="clearlist.html">ClearList()</a> 

</Blockquote><p><b>已支持操作系统 </b><Blockquote>所有</Blockquote></p><center><a href=index.html>List Index</a> - <a href=changecurrentelement.html>ChangeCurrentElement()</a> -&gt;



</body></html>